package nongchang.kuaijiecaifu.com.ncapp_android.common.fragment;

import android.content.Context;


import com.trello.rxlifecycle.components.support.RxFragment;
import com.umeng.analytics.MobclickAgent;


import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.API;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.base.Response;
import rx.Observable;

public class BaseFragment extends RxFragment {

    public BaseFragment() {
    }

    public <T extends Response> Observable.Transformer<T, T> checkOnLifecycle() {
        return observable -> observable
                .compose(bindToLifecycle())
                .compose(API.checkOn(getContext()));
    }
    public <T extends Response> Observable.Transformer<T, T> catchOnLifecycle() {
        return observable -> observable
                .compose(bindToLifecycle())
                .compose(API.catchOn(getContext()));
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(getActivity());
        MobclickAgent.setSessionContinueMillis(10000);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(getActivity());
    }
}
